Industry = function(){
	return {
		
		initGrid : function() {
			$('#industryDataGrid').datagrid({
				url				: basePath + '/pc/industry/list.htm',
				fit				: true,
				fitColumns		: true,
				striped			: true,
				rownumbers		: true,
				autoRowHeight	: true,
				singleSelect    : false,
				nowrap			: true,
				pagination		: true,
				pageSize        : 20,
				pageList        : [10, 20, 30, 40, 50],
				method 			: 'POST',
				columns			: [[
				    {field : 'industryId',          title : '行业ID',       width : 100,   checkbox : true},
				    {field : 'industryName',        title : '行业名称',     width : 100},
				    {field : 'channelName',         title : '所属频道',     width : 100},
				    {field : 'industryLife',        title : '生命周期',     width : 100}
				]],
				toolbar     : [{
					text    : '添加',
					iconCls : 'add',
					handler : function() {
						Industry.addIndustry();
					}
				}, {
					text    : '修改',
					iconCls : 'edit',
					handler : function() {
						Industry.editIndustry();
					}
				}, {
					text    : '删除',
					iconCls : 'remove',
					handler : function() {
						Industry.removeIndustry();
					}
				}, {
					text    : '刷新',
					iconCls : 'reload',
					handler : function() {
						Industry.reload();
					}
				}]
			});
		},
		
		addIndustry : function() {
			Ict.warn("该功能暂未开放，请确认!");
			return;
			Ict.openWin("添加行业", 450, 250, "/pc/industry/add.htm");
		},
		
		editIndustry : function() {
			var rows = $("#industryDataGrid").datagrid("getSelections");
			if(rows.length == 0) {
				Ict.warn("没有选中记录!");
			} else if(rows.length == 1) {
				var industryId = rows[0].industryId;
				Ict.openWin("编辑行业", 450, 250, "/pc/industry/edit.htm?industryId=" + industryId);
			} else {
				Ict.warn("请选择一条记录!");
			}
		},
		
		removeIndustry : function() {
			Ict.warn("该功能暂未开放，请确认!");
			return;
			var rows = $('#industryDataGrid').datagrid('getSelections');
			if(!rows || 0 == rows.length) {
				Ict.warn("请选择一条记录!");
   				return;
			}
			var idArray = "";
			for(var i = 0; i < rows.length; i++) {
				idArray += rows[i].industryId + ",";
			}
			idArray = idArray.substring(0, idArray.length - 1);
			Ict.confirm("确定要删除所选记录?", function(btn) {
				if(btn) {
					$.post("/pc/industry/remove.htm", {'industryIds' : idArray}, function(data) {
						if(data == "SUCCESS") {
							Ict.info("删除成功!", function() {
								$("#industryDataGrid").datagrid("reload");
				    		});
						} else {
							Ict.error("删除失败!");
						}
					});
				}
			});
		},
		
		reload : function() {
			$('#industryDataGrid').datagrid('reload');
		},
		
		addSearchBox : function(width) {
			$('.searchbox').css({'width': width+'px'});
			$('.searchbox-text').css({'width': eval(width-20)+'px'});
			$('.datagrid-toolbar').append($('.serarchbox'));
			$('.datagrid-toolbar').append($('#tbar'));
		},
		
		doSearch : function(value) {
			$('#industryDataGrid').datagrid({
				queryParams   : {
					'keyword' : $.trim(value)
				},
				pageNumber    : 1,
				toolbar       : '#toolbar'
			});
		},
		
		init : function() {
			Industry.initGrid();
			Industry.addSearchBox(250);
		}
	};
}();

$(function(){
	Industry.init();
});